package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ZhuanjiaBiandongHistory;
import com.ruoyi.system.service.IZhuanjiaBiandongHistoryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家变动历史Controller
 * 
 * @author ruoyi
 * @date 2023-02-08
 */
@Controller
@RequestMapping("/system/biandonghistory")
public class ZhuanjiaBiandongHistoryController extends BaseController
{
    private String prefix = "system/biandonghistory";

    @Autowired
    private IZhuanjiaBiandongHistoryService zhuanjiaBiandongHistoryService;

    @RequiresPermissions("system:biandonghistory:view")
    @GetMapping()
    public String biandonghistory()
    {
        return prefix + "/biandonghistory";
    }

    /**
     * 查询专家变动历史列表
     */
    //@RequiresPermissions("system:biandonghistory:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZhuanjiaBiandongHistory zhuanjiaBiandongHistory)
    {
        startPage();
        List<ZhuanjiaBiandongHistory> list = zhuanjiaBiandongHistoryService.selectZhuanjiaBiandongHistoryList(zhuanjiaBiandongHistory);
        return getDataTable(list);
    }

    /**
     * 导出专家变动历史列表
     */
    @RequiresPermissions("system:biandonghistory:export")
    @Log(title = "专家变动历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZhuanjiaBiandongHistory zhuanjiaBiandongHistory)
    {
        List<ZhuanjiaBiandongHistory> list = zhuanjiaBiandongHistoryService.selectZhuanjiaBiandongHistoryList(zhuanjiaBiandongHistory);
        ExcelUtil<ZhuanjiaBiandongHistory> util = new ExcelUtil<ZhuanjiaBiandongHistory>(ZhuanjiaBiandongHistory.class);
        return util.exportExcel(list, "专家变动历史数据");
    }

    /**
     * 新增专家变动历史
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专家变动历史
     */
    @RequiresPermissions("system:biandonghistory:add")
    @Log(title = "专家变动历史", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZhuanjiaBiandongHistory zhuanjiaBiandongHistory)
    {
        return toAjax(zhuanjiaBiandongHistoryService.insertZhuanjiaBiandongHistory(zhuanjiaBiandongHistory));
    }

    /**
     * 修改专家变动历史
     */
    @RequiresPermissions("system:biandonghistory:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZhuanjiaBiandongHistory zhuanjiaBiandongHistory = zhuanjiaBiandongHistoryService.selectZhuanjiaBiandongHistoryById(id);
        mmap.put("zhuanjiaBiandongHistory", zhuanjiaBiandongHistory);
        return prefix + "/edit";
    }

    /**
     * 修改保存专家变动历史
     */
    @RequiresPermissions("system:biandonghistory:edit")
    @Log(title = "专家变动历史", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZhuanjiaBiandongHistory zhuanjiaBiandongHistory)
    {
        return toAjax(zhuanjiaBiandongHistoryService.updateZhuanjiaBiandongHistory(zhuanjiaBiandongHistory));
    }

    /**
     * 删除专家变动历史
     */
    @RequiresPermissions("system:biandonghistory:remove")
    @Log(title = "专家变动历史", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zhuanjiaBiandongHistoryService.deleteZhuanjiaBiandongHistoryByIds(ids));
    }
}
